// pages/search/search.js
const App = getApp()
wx.cloud.init()

const app=getApp()
const db = wx.cloud.database({});

Page({
 
  /**
   * 页面的初始数据
   */
  data:{
    img_urls:[],
    url:[],
    aim_item:''
  },
  onShow: function(options) {
    console.log('img_urls',this.data.aim_item)
    var that=this;
    const _ = db.command
    db.collection('items').where({
      name:/that.data.aim_item/i
    })
    db.collection('items').where({
      name:db.RegExp({
        regexp:that.data.aim_item,
        options:'i',
      })
    })
    .get({
      success: res =>{
        console.log('res.data',res.data);

        this.setData({
          img_urls:res.data
        })
      },
    })
  },
  tapName: function(event){
    console.log(event)
    var Name=event.currentTarget.dataset.hi;
    console.log('first',Name)
    wx.redirectTo({
      url: '/pages/details/details?Name='+Name,
    })
  },
  bindinput(e){
    var that = this
    var search =e.detail.value;
    //var resVlu=res.detail.value
    console.log(search)
    that.setData({
      aim_item:search,
    })
  },
  get_result(res){
  console.log(res)
  var that =this
  wx.showLoading({
    title: '数据搜索中......',
  })
  that.onShow()
  wx.hideLoading({
    success: (res) => {},
  })
},
})